package com.ice.crm.listener;

import com.ice.crm.user.mapper.UserMapper;
import com.ice.crm.user.model.User;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.List;

@Component
public class MyServletContextListener implements ServletContextListener {
    @Resource
    private UserMapper userMapper;

    // 进行环境初始化
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        List<User> userList = userMapper.selectNames();
        sce.getServletContext().setAttribute("userListNames", userList);
    }
}
